﻿using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Controls;

namespace School
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void 欧氏距离ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DistanceSettingsForm form = new DistanceSettingsForm(axMapControl1);
            form.ShowDialog();
        }

        private void 栅格转面ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (RasterToPolygonForm form = new RasterToPolygonForm(axMapControl1))
            {
                form.ShowDialog();
            }
        }

        private void 按属性选择图层ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (AttributeSelectionForm form = new AttributeSelectionForm(axMapControl1))
            {
                form.ShowDialog();
            }
        }

        private void 坡度ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Slope form = new Slope(axMapControl1);
            form.ShowDialog();
        }

        private void 打开mxdToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //文件路径名称,包含文件名称和路径名称
            string strName = null;

            //定义OpenFileDialog，获取并打开地图文档
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Title = "打开MXD";
            openFileDialog.Filter = "MXD文件（*.mxd）|*.mxd";
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                strName = openFileDialog.FileName;
                if (strName != "")
                {
                    this.axMapControl1.LoadMxFile(strName);
                    axMapControl1.ActiveView.Refresh(); // 刷新地图控件
                }
            }
            //地图文档全图显示
            this.axMapControl1.Extent = this.axMapControl1.FullExtent;
        }

        private void 添加数据ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ICommand cmd = new ControlsAddDataCommandClass();
            cmd.OnCreate(this.axMapControl1.Object);
            cmd.OnClick();
        }

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
